<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
		#allmap{height:500px;width:100%;}
		#r-result{width:100%;}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=**************************"></script>
	
	<title>添加/删除覆盖物</title>
</head>
<body>
	<div id="allmap"></div>
</body>
</html>


<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap",{enableMapClick:false});
	var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 15);
    var last_point;
    var myIcon = new BMap.Icon('./heli2.png', new BMap.Size(40, 61), {
                        offset: new BMap.Size(0, 0), // 指定定位位置
						
                        imageOffset: new BMap.Size(0, 0) // 设置图片偏移
						
                    });
	var mk = new BMap.Marker(point,{icon:myIcon,rotation: 90,title: '11111'});//创建标注图标
	map.addOverlay(mk);//将标注添加到地图中

function draw_trail(lon,lat){
	var t = new BMap.Point(lon,lat);
	map.removeOverlay(mk); 
		mk = new BMap.Marker(t,{icon:myIcon,rotation:0,title: '11111'});//创建标注图标
	    map.addOverlay(mk);//将标注添加到地图中
	var polyline = new BMap.Polyline([
			last_point,
			t
		], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});   //创建折线
	map.addOverlay(polyline); 
	
	last_point = t; 
}
map.addEventListener('mousemove',function(e){

draw_trail(e.point.lng,e.point.lat);

})
</script>


	
	